package sanshui.system.trade.factory.data;

import sanshui.system.trade.model.DataLoadModel;

import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.stream.Stream;

public class DataManager implements IDataManager {

    @Override
    public TickData loadTickData(String csvPath) {
        TickData tickData = new TickData();
//        try (Stream<String> stream = Files.lines(Paths.get(csvPath))) {
//            stream.parallel().forEach(line -> {
//                String[] arr = line.split(",");
//                long timestamp = parseTimestamp(arr[0]);
//                double price = Double.parseDouble(arr[1]);
//                long volume = Long.parseLong(arr[2]);
//
//                // 按分片写入Native Memory
//                int index = tickData.getCurrentIndex();
//                tickData.getNativeBuffer().putLong(index, timestamp);
//                tickData.getNativeBuffer().putDouble(index + 8, price);
//                tickData.getNativeBuffer().putLong(index + 16, volume);
//                tickData.incrementIndex();
//            });
//        }
        return tickData;
    }

    @Override
    public TickData loadTickData(DataLoadModel dataLoadModel) {
        switch (dataLoadModel.getTradeMarket()) {
            case A_GU:
                break;
            case OKE:
                break;
        }
        return null;
    }
}
